package pl.put.augrelshooter.activities;

import pl.put.augrelshooter.R;
import pl.put.augrelshooter.adapters.MainMenuAdapter;
import pl.put.augrelshooter.adapters.items.MainMenuItem;
import pl.put.augrelshooter.dataproviders.MainMenuDataProvider;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class MainActivity extends Activity {

	private MainMenuDataProvider dataProvider;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		dataProvider = new MainMenuDataProvider(this);

		final ListView mainMenuListView = (ListView) findViewById(R.id.mainMenuListView);
		mainMenuListView.setAdapter(new MainMenuAdapter(getBaseContext(), dataProvider.getAllMainMenuItems()));

		mainMenuListView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				Intent intent = ((MainMenuItem) mainMenuListView.getAdapter().getItem(position)).getIntent();
				startActivity(intent);
			}
		});

	}
}
